package cn.bx.bid.service;

import cn.bx.bid.dao.DepartmentDao;
import cn.bx.bid.entity.Department;
import cn.bx.bid.entity.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*@Scope("prototype")
@Transactional(readOnly = true)*/
@Service
public class DepartmentService {
	public static final int PAGE_SIZE = Page.PAGE_SIZE;


	@Autowired
	private DepartmentDao Dao;


	public Department find(long id) {
			return Dao.find(id);
	}

	// 添加采购
	public int add(Department p) {
			return Dao.add(p);
	}

	// 模糊分页查询
	public Page<Department> paging(int pageNo, int limit, String dname) {
			List<Department> list = Dao.search(pageNo, limit, dname);
			int total = Dao.searchTotal(dname);
			Page<Department> p = new Page<>(total, limit, list);
			return p;
	}

	// 更新
	public int update(Department d) {
			return Dao.update(d);
	}

	// 批量删除
	public int delALL(long[] ids) {
			return Dao.delALL(ids);
	}

	// 单个删除
	public int del(long ids) {
		return Dao.del(ids);
	}

    public List<Department> findALL() {
		return Dao.findALL();
    }
}
